/*
 *  WObject.h
 *  GLRender
 *
 *  Created by Patrick zulian on 5/4/10.
 *  Copyright 2010 University  of Lugano. All rights reserved.
 *
 */

#ifndef W_OBJECT_H
#define W_OBJECT_H

#include "Base.h"
#include "AbstractRenderer.h"
#include "CollisionReaction.h"

class Bonus;

class WObject {
protected:
	Point3d _position; 
	double _mass, radius;
	double life,strength;
	bool _alive, _insideWorld;
	CollisionReaction reaction;
public:
	WObject(const Point3d &position,  double _mass = 1.0, double radius = 1.0);
	
	virtual
	void renderOn(AbstractRenderer *renderer)=0;
	
	inline
	const double getRadius() const { return radius; }
	
	inline
	CollisionReaction & getReaction () { return reaction; }
	
	
	virtual
	~WObject() { }
	
	virtual
	void step(const double tau) = 0;
	
	
	inline
	const double mass() const
	{
		return _mass;
	}
	
	inline
	const bool alive() const 
	{
		return _alive;
	}
	
	inline
	bool & alive()
	{
		return _alive;
	}
	
	inline
	bool & insideWorld()
	{
		return _insideWorld;
	}
	
	
	inline
	const Point3d position() const 
	{
		return _position;
	}
	
	inline
	Point3d& position() 
	{
		return _position;
	}
	
	virtual
	const Point3d velocity() const 
	{
		return Point3d(0,0,0);
	}
	
	virtual inline void setLife (double life) { this->life = life; }
	inline double const getLife() const {return life;}
	
	double getStrength () const { return strength; }
	
	void setStrength (double strength) { this->strength = strength; }
	
//	inline 
//	WObject * getMe() { return this; }
//	
	//void onSpawned();
	//void onHit(Weapon &weapon, WObject &from);
	//void onKilled();
	virtual void onCollision(WObject * from); 
	virtual void applyBonus (Bonus *b);
	virtual bool isBonus () { return false; }
	//void onGameEnded();
	//void onGameStarted();
	//bool isPlayer()
	
	
};


#endif
